package com.family.web.controller.pedigree;


import com.family.common.core.controller.BaseController;
import com.family.common.core.domain.AjaxResult;
import com.family.common.core.page.TableDataInfo;
import com.family.pedigree.domain.FamilyCompany;
import com.family.pedigree.service.IFamilyCompanyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 公司简介表 前端控制器
 * </p>
 *
 * @author forever
 * @since 2025-01-16
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/family/company")
public class FamilyCompanyController extends BaseController {

    private final IFamilyCompanyService familyCompanyService;

    @PostMapping
    public AjaxResult add(@Validated @RequestBody FamilyCompany familyCompany){
        familyCompanyService.add(familyCompany);
        return AjaxResult.success();
    }

   @PutMapping
   public AjaxResult update(@Validated @RequestBody FamilyCompany familyCompany){
       familyCompanyService.edit(familyCompany);
       return AjaxResult.success();
   }

   @DeleteMapping("/{companyId}")
    public AjaxResult delete(@PathVariable("companyId") Long companyId){
       familyCompanyService.delById(companyId);
       return AjaxResult.success();
   }

   @GetMapping("/page")
    public TableDataInfo page(FamilyCompany familyCompany){
       startPage();
       return getDataTable(familyCompanyService.getCompanyPage(familyCompany));
   }


}
